<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
       /* 
            ascii码:每一个按键，都有一个数值对应。
            应用：可以判断用户按下了哪个键。
            keypress: 可以区分大小写
            keypress: 功能键不能触发 
        
        */
       // A 65  a  97  
       document.addEventListener('keyup', function (e) {
            console.log('---keyup------------' + e.key + "-----" + e.keyCode);
        });
        document.addEventListener('keydown', function (e) {
            console.log('---keydown------------' + e.key + "-----" + e.keyCode);
        });
        document.addEventListener('keypress', function (e) {
            console.log('---keypress------------' + e.key + "-----" + e.keyCode);
        });
    </script>
</body>

</html>